﻿@model EvincePayroll.Data.LeaveMasterData
@{
    var leaveMasterData = ViewBag.LeaveMaster as EvincePayroll.Data.LeaveMasterData;
    var list = ViewBag.List as EvinceUI.Models.TotalLeaves;
    ViewBag.Title = "LeaveMaster";
}
<script type="text/javascript">
    $(document).ready(function () {
        $('#roleId').change(function () {
            var roleId = $('#roleId').val();
            $('#currentLeaveData').load('/LeaveRequests/_CurrentLeaveData?roleId=' + roleId);
        });
        $('#LeaveMasterUpdate').submit(function () {
            var roleId = $('#roleId').val();
            var leaveMasterId = $('#leaveMasterId').val();
            if (leaveMasterId != undefined && roleId != '') {
                var errorFlag = false;
                $('.requireded').each(function () {
                    if ($(this).val() == '') {
                        if ($(this).prev().attr('class') != 'error') {
                            $(this).before('<span class="error"></span>');
                        }
                        $(this).css({
                            border: '1px solid red'
                        });
                        errorFlag = true;
                    } else {
                        if ($(this).prev().attr('class') == 'error') {
                            $(this).prev().remove();
                        }
                    }
                });
                if (errorFlag == false) {
                    var temp = confirm('Are you sure want to Update?');
                    if (temp == true) {
                        $.ajax({
                            type: "POST",
                            url: "/LeaveRequests/CreateLeaveMaster?leaveMasterId=" + leaveMasterId,
                            data: $(this).serialize(),
                            dataType: 'json',
                            success: function (result) {
                                $('#currentLeaveData').load('/LeaveRequests/_CurrentLeaveData?roleId=' + roleId);
                                return false;
                            }
                        });
                    }
                }
            }
            return false;
        });
    });


</script>
<form id="LeaveMasterUpdate" method="post" action="CreateLeaveMaster">
<div class="grid_10">
    <div class="box round">
        <div id="demo">
            <h2>Leave Manager</h2>
            <div class="block" style="width:50%;">
           <br />
          <ul style="border: 1px solid gray;">
          
          <li>Select Role</li>
          @Html.DropDownListFor(m => m.RoleId, new SelectList(ViewBag.UserRoleList as System.Collections.IEnumerable, "UserRoleId", "UserRole"), "", new { id = "roleId", @class = "required",@style="margin:40px;" })                    
          
          <br />


          <div id="currentLeaveData"></div>
                            
                            @*<li id="li_1">
                                <label class="description" for="element_2">
                                    Sick Leave
                                </label>
                                <br />
                                <div>
                                @Html.DropDownListFor(m => m.Sickleave, new SelectList(ViewBag.List as System.Collections.IEnumerable, "Value", "Text"), "", new { style = "width:30%", @class = "requireded",id="sickDropDown" })
                                </div>
                            </li>
                            
                             <li id="li_2">
                                <label class="description" for="element_2">
                                    Privilage Leave
                                </label>
                                <br />
                                <div>
                                @Html.DropDownListFor(m => m.PrivilageLeave, new SelectList(ViewBag.List as System.Collections.IEnumerable, "Value", "Text"), "", new { style = "width:30%", @class = "requireded",id="pLDropDown" })
                                </div>
                            </li>
                             <li id="li_3">
                                <label class="description" for="element_2">
                                    Casual Leave
                                </label>
                                <br />
                                <div>
                                @Html.DropDownListFor(m => m.CasualLeave, new SelectList(ViewBag.List as System.Collections.IEnumerable, "Value", "Text"), "", new { style = "width:30%", @class = "requireded", id = "cLDropDown" })
                                </div>
                            </li>
                             <li id="li_4">
                                <label class="description" for="element_2">
                                    Leave Without Pay
                                </label>
                                <br />
                                <div>
                                @Html.DropDownListFor(m => m.LeaveWithoutPay, new SelectList(ViewBag.List as System.Collections.IEnumerable, "Value", "Text"), "", new { style = "width:30%", @class = "requireded", id = "lWPDropDown" })
                                </div>
                            </li>
                            <li id="li_5">
                                <br />
                                <button class="btn btn-orange" runat="server">
                                    Update</button>
                            </li>*@
                            <br />
                        </ul>
                   
            </div>
        </div>
    </div>
</div>
</form>